﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcSecCamStore.Models;

namespace MvcSecCamStore.Controllers
{
    public class StoreController : Controller
    {
        SecCamStoreEntities storeDB = new SecCamStoreEntities();

        //
        // GET: /Store/

        public ActionResult Index()
        {
            var camtypes = storeDB.Camtypes.ToList();

            return View(camtypes);
        }

        //
        // GET: /Store/Browse?camtype=BOX

        public ActionResult Browse(string camtype)
        {
            // Retrieve Camera type and its Associated Cameras from database
            var camtypeModel = storeDB.Camtypes.Include("Cams")
                .Single(g => g.Name == camtype);

            return View(camtypeModel);
        }

        //
        // GET: /Store/Details/5

        public ActionResult Details(int id)
        {
            var cam = storeDB.Cams.Find(id);

            return View(cam);
        }

        //
        // GET: /Store/CamtypeMenu

        [ChildActionOnly]
        public ActionResult CamtypeMenu()
        {
            var camtypes = storeDB.Camtypes.ToList();

            return PartialView(camtypes);
        }
    }
}